package com.chenjie.executor.day02;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Main3 {
    public static void main(String[] args) {
        //创建自定义task
        Result result = new Result();
        //创建异步任务FutureTask
        FutureTask<String> futureTask=new FutureTask(result);
        //创建线程，把task放进去
        Thread thread = new Thread(futureTask);
        //启动线程
        thread.start();
        try {
            String value = futureTask.get();
            System.out.println(value);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
}
